package designpattern.factorial;

import java.math.BigInteger;

public class FunctionSolution {
    public static void main(String[] args) {
        System.out.println(factor3(150));

    }

    static int factor(int n) {
        int result = 1;
        for (int i = 2; i <= n; i++)
            result *= i;
        return result;
    }

    static long factor2(int n) {
        long result = 1;
        for (int i = 2; i <= n; i++)
            result *= i;
        return result;
    }

    static BigInteger factor3(int n) {
        BigInteger result = new BigInteger("1");
        for (int i = 2; i <= n; i++)
            result = result.multiply(new BigInteger(Integer.toString(i)));

        return result;
    }
}
